package com.rp.system.log.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rp.common.result.ResultDTO;
import com.rp.common.aspect.annotetion.AutoLog;
import com.rp.system.log.entity.SysLog;
import com.rp.system.log.service.SysLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 系统日志表 前端控制器
 * </p>
 *
 * @author vicente
 * @since 2020-12-17
 */
@RestController
@RequestMapping("/sys-log")
@Api(tags = "操作日志")
public class SysLogController {

    @Autowired
    private SysLogService sysLogService;

    @GetMapping("/list")
    @ApiOperation(value = "分页列表")
    @AutoLog(value = "操作日志-分页列表")
//    @RequiresPermissions("SysLog:list")
    public ResultDTO<IPage<SysLog>> list(
            @RequestParam(defaultValue = "1",required = false) @ApiParam(value = "当前页面") int pageNum,
            @RequestParam(defaultValue = "20",required = false) @ApiParam(value = "每页显示的数量") int pageSize){
        QueryWrapper<SysLog> queryWrapper = new QueryWrapper<SysLog>().orderByDesc("create_time");
        return ResultDTO.success().data(sysLogService.page(new Page<>(pageNum, pageSize),queryWrapper));
    }
}
